package com.oracle.controller;

import com.oracle.common.PageResult;
import com.oracle.common.R;
import com.oracle.pojo.Bj;
import com.oracle.service.BjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("bj")
public class BjController {

    @Autowired
    private BjService bjService;

    @GetMapping("find")
    public List<Bj> findlist()
    {
        List<Bj> list=bjService.findList();
        return list;
    }

    @PostMapping("find2")
    public R<Bj> findPages2(@RequestBody Bj bj, Integer pageNo, Integer pageSize)
    {
        if(ObjectUtils.isEmpty(pageNo)){
            pageNo = 1;
        }

        if(ObjectUtils.isEmpty(pageSize)){
            pageSize = 10;
        }

        PageResult pages = bjService.findPages(pageNo,pageSize,bj);
        return R.success(pages);
    }
}
